package ar.com.larctest.adapters;

import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

import ar.com.larctest.entities.Temperature;

public class SpinnerTemperatureAdapter extends ArrayAdapter<Temperature>
{
	public List<Temperature> items;
	Activity activity;

	public SpinnerTemperatureAdapter(Activity activity, int textViewResourceId, List<Temperature> lstTemperatures) {
		super(activity, textViewResourceId, lstTemperatures);
		this.items = lstTemperatures;
		this.activity = activity;
	}

	@Override
	public int getCount() {
		return items.size();
	}

	@Override
	public Temperature getItem(int position) {
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		return (items.get(position)).getIdTemperature();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {

		TextView label = new TextView(activity); 
        label.setTextColor(Color.BLACK);
        label.setText(items.get(position).getDescription());

		return label;	
	}
	
	@Override 
    public View getDropDownView(int position, View convertView, ViewGroup parent) { 
        TextView label = new TextView(activity); 
        label.setTextColor(Color.BLACK); 
        label.setText(items.get(position).getDescription());
 
        return label; 
    }
}
